package com.wn.production.web;

import com.wn.common.PageBean;
import com.wn.common.ResponseEntity;
import com.wn.entity.Process;
import com.wn.production.service.ProcessService;
import com.wn.production.vo.ProcessVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/production/process")
@Slf4j
@Validated
public class ProcessController {
    @Autowired
    private ProcessService processService;


    /**
     * @param process
     * @return com.wn.common.ResponseEntity
     * @ author zc
     * @ date 2022/10/26 20点08分
     * @ Description 产品名称,工艺流程文件,物料档案的登记编号
     */
    @RequestMapping("add")
    public ResponseEntity add(@Validated Process process) {
        processService.insert(process);
        return ResponseEntity.success;
    }

    @RequestMapping("getByCondition")
    public ResponseEntity getByCondition(@RequestBody ProcessVo processVo) {
        PageBean<Process> pageBean = processService.getByCondition(processVo);
        return new ResponseEntity(pageBean);
    }
}
